package com.xuzao.developer.utils;

import com.xuzao.developer.base.model.SysUser;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author xuzao
 * @description
 * @date 2019-08-22 18:39
 */
public class LoginUserInfoUtil {
    public static SysUser getLoginUser(){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        HttpSession session = request.getSession(true);
        Object object = session.getAttribute("user");
        if (object != null){
            return (SysUser)object;
        }
        return null;
    }
}
